class FuncUtil {
	public constructor() {
	}
	/**
	 * 创建并且展示动画 fileName：文件名称，name:骨骼动画名称，animaName：动画名称，animaTimes：动画执行次数
	 * "zouludonghua2", "Sprite", 1
	 */
	 public static dragonBoneTween(fileName:string,animaName:string, animaTimes:number=-1) {
         //读取一个骨骼数据,并创建实例显示到舞台
        var skeletonData = RES.getRes(fileName+"_ske_json");
        var textureData = RES.getRes(fileName+"_tex_json");
        var texture = RES.getRes(fileName+"_tex_png");

        var factory = new dragonBones.EgretFactory();
		// 将动画数据解析并缓存到内存中
		factory.parseDragonBonesData(skeletonData);
		// 将动画用到的图片数据解析
        factory.addTextureAtlasData(factory.parseTextureAtlasData(textureData, texture));
		// 生成动画
        let armature = factory.buildArmature(animaName);
        dragonBones.WorldClock.clock.add(armature);
		// 播放动画
		armature.animation.play(animaName,animaTimes);
		return armature;
    }
	/**
     * 根据name关键字创建一个Bitmap对象。name属性请参考resources/resource.json配置文件的内容。
     * Create a Bitmap object according to name keyword.As for the property of name please refer to the configuration file of resources/resource.json.
     */
	public static createBitmapByName(name: string): egret.Bitmap {
		let result = new egret.Bitmap();
		let texture: egret.Texture = RES.getRes(name);
		result.texture = texture;
		return result;
	}
	/**
	 *根据r g b,转换为hex 
	 */
	public static rgbChange(r, g, b) {
		var hex = "0x" + ((r << 16) + (g << 8) + b).toString(16);
		return hex;
	};
	
	/**获取存取数据的key */
	public static getKey() {
		var today = new Date();
		var firstDay = new Date(today.getFullYear(), 0, 1);
		var dayOfWeek = firstDay.getDay();
		var spendDay = 1;
		if (dayOfWeek != 0) {
			spendDay = 7 - dayOfWeek + 1;
		}
		firstDay = new Date(today.getFullYear(), 0, 1 + spendDay);
		var d = Math.ceil((today.valueOf() - firstDay.valueOf()) / 86400000);
		var result = Math.ceil(d / 7);
		return new Date().getFullYear() + "" + (result + 1);
	}
	
}